﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using Axis.BusinessObject.Research;
using Axis.Web.Administrator.Views.Project;
using Axis.BusinessObject.Core;

namespace Axis.Web.Views.Project.Service
{
    /// <summary>
    /// Summary description for ProjectService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    [System.Web.Script.Services.ScriptService]
    public class ProjectService : System.Web.Services.WebService
    {

        CMemberList member = new CMemberList();
        [WebMethod(EnableSession = true)]
        public string GetNextQuestion(string input)
        {
            if (Session["MEMBERINFO"] != null)
                member = Session["MEMBERINFO"] as CMemberList;
            CProjectUI UI = new CProjectUI(member);
            IList<CQuestionaire> listPath = UI.GetQuestionareList(input);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(listPath);
            return strJSON;
        }
        [WebMethod(EnableSession = true)]
        public string GeResponseOptionByQuestionID(int QuestionID)
        {
            CResponseUI UI = new CResponseUI();
            var Map = UI.GetResponseListByQuestionnaire(QuestionID);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(Map);
            return strJSON;
        }
        [WebMethod(EnableSession = true)]
        public string GeResponseOptionByQuestionID2(string input)
        {
            CResponseUI UI = new CResponseUI();
            var Map = UI.GetResponseListByQuestionnaire2(input);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(Map);
            return strJSON;
        }
        [WebMethod(EnableSession = true)]
        public string GetQuestionListID(int QuestionID, int ProjectID)
        {
            CQuestionUI UI = new CQuestionUI();
            var Map = UI.GetQuestionareList(QuestionID, ProjectID);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(Map);
            return strJSON;
        }
        [WebMethod(EnableSession = true)]
        public string GetProjectByMember()
        {
            if (Session["MEMBERINFO"] != null)
                member = Session["MEMBERINFO"] as CMemberList;
            CProjectUI UI = new CProjectUI(member);
            return UI.GetProjectByMember();
        }
        [WebMethod(EnableSession = true)]
        public string GetUserGroup(string pMemberGroupID)
        {
            if (Session["MEMBERINFO"] != null)
                member = Session["MEMBERINFO"] as CMemberList;
            CProjectUI UI = new CProjectUI(member);
            return UI.GetUserGroup(pMemberGroupID);
        }
    }
}
